package com.diudiutechnology.www.yadiudiu.yadiudiu.mine.MyActivity;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;

import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.diudiutechnology.www.yadiudiu.util.http.HttpClient;
import com.diudiutechnology.www.yadiudiu.util.http.JsonTools;
import com.diudiutechnology.www.yadiudiu.util.utils.Constant;
import com.diudiutechnology.www.yadiudiu.util.utils.Dialog;
import com.diudiutechnology.www.yadiudiu.util.utils.ImgUtils;
import com.diudiutechnology.www.yadiudiu.util.utils.MyProgressDialog;
import com.diudiutechnology.www.yadiudiu.util.utils.RatingBar;
import com.diudiutechnology.www.yadiudiu.util.utils.Sundry;
import com.diudiutechnology.www.yadiudiu.util.utils.ToastUtils;
import com.diudiutechnology.www.yadiudiu.util.utils.UserInfoUtils;
import com.diudiutechnology.www.yadiudiu.util.view.CircleImageView;
import com.diudiutechnology.www.yadiudiu.util.view.ListViewForScrollView;
import com.diudiutechnology.www.yadiudiu.yadiudiu.main.MyActivity.LoginActivity;
import com.diudiutechnology.www.yadiudiu.yadiudiu.mine.MyAdapter.OrderDetailsAdapter;
import com.diudiutechnology.www.yadiudiu.yadiudiu.model.MerchantsTypeModel;
import com.diudiutechnology.www.yadiudiu.yadiudiu.model.MineFragmentModel;
import com.diudiutechnology.www.yadiudiu.yadiudiu.model.OrderDetailsModel;
import com.diudiutechnology.www.yadiudiu.yadiudiu.model.WaitingModel;
import com.diudiutechnology.www.yadiudiu.R;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;


import org.xutils.common.Callback;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/9/1.
 * 商品中心订单详情
 * 0、待接单  1、已接单  2、已完成
 */

public class OrderDetailsActivity extends Activity implements View.OnClickListener, Callback.CommonCallback<String> {
    @Bind(R.id.retur)//返回
            LinearLayout retur;

    @Bind(R.id.contact_layout)//联系骑手展示详
            RelativeLayout contact_layout;

    @Bind(R.id.user_evaluation_layout)//商品评价
            LinearLayout user_evaluation_layout;

    @Bind(R.id.purchase_layout)//购买商品
            LinearLayout purchase_layout;

    @Bind(R.id.listview)//商品
            ListViewForScrollView listview;

    @Bind(R.id.real)//实付金额
            TextView real;
    @Bind(R.id.ordernumber_layout)//取单号layout
            LinearLayout ordernumber_layout;

    @Bind(R.id.ordernumber)//取单号
            TextView ordernumber;
    @Bind(R.id.number)//订单号
            TextView number;
    @Bind(R.id.time)//时间
            TextView time;
    @Bind(R.id.method_payment)//支付方式
            TextView method_payment;
    @Bind(R.id.shipping_layout)//配送
            RelativeLayout shipping_layout;

    @Bind(R.id.name)//名字
            TextView name;
    @Bind(R.id.address)//地址
            TextView address;
    @Bind(R.id.phone_layout)//订单电话
            LinearLayout phone_layout;
    @Bind(R.id.noider)//暂无骑手
            TextView noider;

    @Bind(R.id.therider)//骑手
            RelativeLayout therider;
    @Bind(R.id.personal_icon)//骑手头像
            CircleImageView personal_icon;
    @Bind(R.id.name_shipping)//骑手名称
            TextView name_shipping;

    @Bind(R.id.order_phone)//骑手电话
            LinearLayout order_phone;
    @Bind(R.id.comments)//评论内容
            TextView comments;

    @Bind(R.id.rating)//评论分数
            RatingBar rating;

    @Bind(R.id.standbynote_layout)//备注layout
            LinearLayout standbynote_layout;
    @Bind(R.id.method_payment_layout)//支付方式layout
            LinearLayout method_payment_layout;

    @Bind(R.id.standbynote)//备注
            TextView standbynote;

    @Bind(R.id.method_payment_text)//支付方式
            TextView method_payment_text;
    @Bind(R.id.shipping_text)//配送地址
            TextView shipping_text;

    @Bind(R.id.pickupgoods_layout)//取货地址layout
            RelativeLayout pickupgoods_layout;
    @Bind(R.id.pickupgoodsname)//取货电话
            TextView pickupgoodsname;

    @Bind(R.id.pickupgoodsaddress)//取货地址
            TextView pickupgoodsaddress;
    @Bind(R.id.pickupgoodsorder_phone)//取货电话layout
            LinearLayout pickupgoodsorder_phone;

    Context context;
    String merchanttype = "";//类型
    String Judge_interface = "0";//判断哪个接口   0、获取数据
    String pos = "0";
    String u_id = "";
    String id = "";
    int ints = 0;
    List<WaitingModel> getwjcleaningorder = new ArrayList<>();
    OrderDetailsAdapter adapter;
    private MyProgressDialog mDialog;
    AlertDialog alertDialog;
    private DisplayImageOptions options;
    private ImageLoader imageLoader;
    String disttel = "";//订单电话
    String phone = "";//骑手电话
    String pickup_phone = "";//取货电话

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_order_details);
        ButterKnife.bind(this);
        context = this;
        initView();
    }

    private void initView() {
        retur.setOnClickListener(this);
        order_phone.setOnClickListener(this);
        phone_layout.setOnClickListener(this);
        pickupgoodsorder_phone.setOnClickListener(this);
        options = ImgUtils.mImageOptions();
        imageLoader = ImageLoader.getInstance();
        imageLoader.init(ImageLoaderConfiguration.createDefault(context));


        if (getIntent() != null) {
            pos = getIntent().getStringExtra("pos");
            u_id = getIntent().getStringExtra("u_id");
            ints = getIntent().getIntExtra("ints", 0);
            getwjcleaningorder = (List<WaitingModel>) getIntent().getSerializableExtra("data");
        }
        MineFragmentModel mineFragmentModel = UserInfoUtils.readUserInfo(this);
        merchanttype = mineFragmentModel.getMerchanttype();
     //   merchanttype = "6";
        if (pos.equals("0")) {
            contact_layout.setVisibility(View.GONE);
            user_evaluation_layout.setVisibility(View.GONE);
        } else if (pos.equals("1")) {
            contact_layout.setVisibility(View.VISIBLE);
            user_evaluation_layout.setVisibility(View.GONE);
        } else if (pos.equals("2")) {
            contact_layout.setVisibility(View.VISIBLE);
            user_evaluation_layout.setVisibility(View.VISIBLE);
        }
        adapter = new OrderDetailsAdapter(context, merchanttype);
        listview.setAdapter(adapter);
        initData();
    }

    private void initData() {
        WaitingModel waitingModel = getwjcleaningorder.get(ints);
        id = waitingModel.getId();
        if (merchanttype.equals("1")) {//买房商家
            contact_layout.setVisibility(View.GONE);
            ordernumber_layout.setVisibility(View.GONE);
            method_payment_text.setText("楼盘名称");
            shipping_text.setText("联系方式");
            address.setVisibility(View.GONE);
            standbynote_layout.setVisibility(View.GONE);
            purchase_layout.setVisibility(View.GONE);
            if (!pos.equals("0")) {
                user_evaluation_layout.setVisibility(View.VISIBLE);
            }

        } else if (merchanttype.equals("2")) {//购车商家
            contact_layout.setVisibility(View.GONE);
            ordernumber_layout.setVisibility(View.GONE);
            method_payment_text.setText("车型名称");
            shipping_text.setText("联系方式");
            address.setVisibility(View.GONE);
            standbynote_layout.setVisibility(View.GONE);
            purchase_layout.setVisibility(View.GONE);
            if (!pos.equals("0")) {
                user_evaluation_layout.setVisibility(View.VISIBLE);
            }
        } else if (merchanttype.equals("3") || merchanttype.equals("5")) {//干洗商家 果蔬商家
            double Unitprice = 0.0;
            List<WaitingModel> getwjcleaningorderdetails = JsonTools.getwjcleaningorderdetails(waitingModel.getDetails());
            if (getwjcleaningorderdetails != null || getwjcleaningorderdetails.size() > 0) {
                for (int j = 0; j < getwjcleaningorderdetails.size(); j++) {
                    double quantity = Double.valueOf(getwjcleaningorderdetails.get(j).getQuantity());
                    double unitprice = Double.valueOf(getwjcleaningorderdetails.get(j).getUnitprice());
                    if (Unitprice == 0.0) {
                        Unitprice = quantity * unitprice;
                    } else {
                        Unitprice = Unitprice + quantity * unitprice;
                    }
                }
                adapter.addItem(getwjcleaningorderdetails);
            }
            DecimalFormat format = new DecimalFormat(",##0.00");
            String Totalprice = format.format(Unitprice);
            real.setText(Totalprice);
        } else if (merchanttype.equals("4")) {//开锁商家
            contact_layout.setVisibility(View.GONE);
            ordernumber_layout.setVisibility(View.GONE);
            method_payment_layout.setVisibility(View.GONE);
            standbynote_layout.setVisibility(View.GONE);
            purchase_layout.setVisibility(View.GONE);
            if (!pos.equals("0")) {
                user_evaluation_layout.setVisibility(View.VISIBLE);
            }
        } else if (merchanttype.equals("6")) {//苦力商家
            contact_layout.setVisibility(View.GONE);
            ordernumber_layout.setVisibility(View.GONE);
            method_payment_text.setText("大概重量");

            purchase_layout.setVisibility(View.GONE);
            pickupgoods_layout.setVisibility(View.VISIBLE);
            if (!pos.equals("0")) {
                user_evaluation_layout.setVisibility(View.VISIBLE);
            }
        } else if (merchanttype.equals("7")) {//快递商家

        } else if (merchanttype.equals("8")) {//家政商家
            List<WaitingModel> getwjcleaningorderdetails = new ArrayList<>();
            WaitingModel model = new WaitingModel();
            model.setProductname(waitingModel.getOrdername());
            model.setQuantity("");
            model.setUnitprice(waitingModel.getOrdermoney() + waitingModel.getServicetime());
            getwjcleaningorderdetails.add(model);
            adapter.addItem(getwjcleaningorderdetails);
            real.setText(waitingModel.getOrdermoney());
            contact_layout.setVisibility(View.GONE);
            ordernumber_layout.setVisibility(View.GONE);
        } else if (merchanttype.equals("9")) {//洗车商家
            List<WaitingModel> getwjcleaningorderdetails = new ArrayList<>();
            WaitingModel model = new WaitingModel();
            model.setProductname(waitingModel.getOrdername());
            model.setQuantity("");
            model.setUnitprice(waitingModel.getOrdermoney());
            getwjcleaningorderdetails.add(model);
            adapter.addItem(getwjcleaningorderdetails);
            real.setText(waitingModel.getOrdermoney());
            contact_layout.setVisibility(View.GONE);
            ordernumber_layout.setVisibility(View.GONE);
            shipping_layout.setVisibility(View.GONE);
            standbynote_layout.setVisibility(View.GONE);
            if (!pos.equals("0")) {
                user_evaluation_layout.setVisibility(View.VISIBLE);
            }
        }
        processproofing();
    }

    //数据
    private void processproofing() {
        if (Sundry.isOpenNetwork(context)) {
            if (Judge_interface == "0") {
                mDialog = new MyProgressDialog(context);
            }
            Judge_interface = "0";

            if (merchanttype.equals("3")) {//干洗商家

                HttpClient.ordermanagede(Constant.ORDERMANAGEDETAILSCLEANING, id, this);
            } else if (merchanttype.equals("5")) {//果蔬商家

                HttpClient.ordermanagede(Constant.ORDERMANAGEVEGETABLESDETAILS, id, this);
            } else {
                String Data = "";
                if (merchanttype.equals("1")) {//买房商家

                    Data = Constant.ORDERMANAGERENTORDERDATAILS;

                } else if (merchanttype.equals("2")) {//购车商家

                    Data = Constant.ORDERMANAGEBUYCARORDERDETAILS;

                } else if (merchanttype.equals("4")) {//开锁商家

                    Data = Constant.ORDERMANAGELOCKORDERDETAILS;

                } else if (merchanttype.equals("6")) {//苦力商家

                    Data = Constant.ORDERMANAGECOOLIEDETAILS;

                } else if (merchanttype.equals("7")) {//快递商家

                } else if (merchanttype.equals("8")) {//家政商家

                    Data = Constant.ORDERMANAGEHOUSEKEEPINGDETAILS;

                } else if (merchanttype.equals("9")) {//洗车商家

                    Data = Constant.ORDERMANAGECAWASHORDERDETAILS;

                }
//                id = "1";
//                u_id = "37";
                HttpClient.housekeepingdetails(Data, id, u_id, this);
            }

        } else {
            ToastUtils.Toastshow(context, getResources().getString(R.string.network));
        }
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.retur:
                finish();
                break;
            case R.id.order_phone:
                processphon(disttel);
                break;
            case R.id.phone_layout:
                processphon(phone);
                break;
            case R.id.pickupgoodsorder_phone:
                processphon(pickup_phone);
                break;
        }
    }

    private void processphon(final String str) {
        alertDialog = Dialog.phonedialog(context, "", str, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(Intent.ACTION_DIAL);
                Uri data = Uri.parse("tel:" + str);
                intent.setData(data);
                context.startActivity(intent);
                alertDialog.dismiss();
            }
        }, "确定", "取消");
    }

    @Override
    public void onSuccess(String result) {
        if (mDialog != null) {
            mDialog.dismiss();
        }
        System.out.println("stringmd5result" + result);
        List<MerchantsTypeModel> getnote = JsonTools.getmerchanttype(result);
        if (getnote != null || getnote.size() > 0) {
            String error = getnote.get(0).getError();
            String mssage = getnote.get(0).getMssage();

            if (error.equals("200")) {
                String content = getnote.get(0).getResult();
                if (merchanttype.equals("1")) {//买房商家
                    processbuyhouse(content);
                } else if (merchanttype.equals("2")) {//购车商家
                    processbuyhouse(content);
                } else if (merchanttype.equals("3") || merchanttype.equals("5")) {//干洗商家 果蔬商家
                    processcleaning(content);
                } else if (merchanttype.equals("4")) {//开锁商家
                    processbuyhouse(content);
                } else if (merchanttype.equals("6")) {//苦力商家
                    processcoolie(content);
                } else if (merchanttype.equals("7")) {//快递商家

                } else if (merchanttype.equals("8")) {//家政商家
                    processhomemaking(content);
                } else if (merchanttype.equals("9")) {//洗车商家
                    processhomemaking(content);

                }
            } else if (error.equals("105")) {
                Intent intent = new Intent(context, LoginActivity.class);
                startActivity(intent);
                ToastUtils.show(context, mssage);
            } else if (error.equals("100")) {

                ToastUtils.show(context, mssage);
            } else if (error.equals("150")) {

                ToastUtils.show(context, mssage);
            } else {

                ToastUtils.show(context, mssage);
            }
        }

    }

    @Override
    public void onError(Throwable ex, boolean isOnCallback) {
        if (mDialog != null) {
            mDialog.dismiss();
        }
        System.out.println("stringmd5result" + ex.getMessage().toString());

        ToastUtils.Toastshow(context, getResources().getString(R.string.server));
    }

    @Override
    public void onCancelled(CancelledException cex) {
        if (mDialog != null) {
            mDialog.dismiss();
        }
        System.out.println("stringmd5result" + cex.getMessage().toString());

        ToastUtils.Toastshow(context, getResources().getString(R.string.server));
    }

    @Override
    public void onFinished() {

    }

    //干洗 蔬果
    private void processcleaning(String content) {
        List<OrderDetailsModel> orderdetails = JsonTools.getOrderdetails(content);
        if (orderdetails != null && orderdetails.size() > 0) {
            String details = orderdetails.get(0).getDetails();
            String horseman = orderdetails.get(0).getHorseman();
            String comment = orderdetails.get(0).getComment();
            List<OrderDetailsModel> orderdetailsdetails = JsonTools.getOrderdetailsdetails(details);
            if (orderdetailsdetails != null && orderdetailsdetails.size() > 0) {
                ordernumber.setText(orderdetailsdetails.get(0).getOddnum());
                number.setText(orderdetailsdetails.get(0).getOrdernumber());
                time.setText(Sundry.getStrTime(4, orderdetailsdetails.get(0).getAddtime()));
                if (orderdetailsdetails.get(0).getOrdertype().equals("2")) {
                    method_payment.setText("微信支付");
                } else if (orderdetailsdetails.get(0).getOrdertype().equals("3")) {
                    method_payment.setText("支付宝支付");
                } else if (orderdetailsdetails.get(0).getOrdertype().equals("4")) {
                    method_payment.setText("银联支付");
                } else if (orderdetailsdetails.get(0).getOrdertype().equals("5")) {
                    method_payment.setText("余额支付");
                }
                if (merchanttype.equals("3")) {//干洗商家 果蔬商家
                    name.setText(orderdetailsdetails.get(0).getDistname() + "    " + orderdetailsdetails.get(0).getDisttel());
                    disttel = orderdetailsdetails.get(0).getDisttel();
                } else if (merchanttype.equals("5")) {
                    name.setText(orderdetailsdetails.get(0).getConsignee() + "    " + orderdetailsdetails.get(0).getPhone());
                    disttel = orderdetailsdetails.get(0).getPhone();
                }
                standbynote.setText(orderdetailsdetails.get(0).getRemark());
                address.setText(orderdetailsdetails.get(0).getAddress());
            }
            if (!pos.equals("0")) {
                List<OrderDetailsModel> getOrderdetailshorseman = JsonTools.getOrderdetailshorseman(horseman);
                if (getOrderdetailshorseman != null && getOrderdetailshorseman.size() > 0) {
                    noider.setVisibility(View.GONE);
                    therider.setVisibility(View.VISIBLE);
                    //头像
                    imageLoader.displayImage(Constant.HTTP + getOrderdetailshorseman.get(0).getAvatar(), personal_icon, options);
                    name_shipping.setText(getOrderdetailshorseman.get(0).getRealname());
                    phone = getOrderdetailshorseman.get(0).getPhone();
                } else {
                    noider.setVisibility(View.VISIBLE);
                    therider.setVisibility(View.GONE);
                }
                if (pos.equals("2")) {
                    List<OrderDetailsModel> getOrderdetailscomment = JsonTools.getOrderdetailscomment(comment);
                    if (getOrderdetailscomment != null && getOrderdetailscomment.size() > 0) {
                        float da = 0;
                        if (!TextUtils.isEmpty(getOrderdetailscomment.get(0).getStar())) {
                            da = Float.valueOf(getOrderdetailscomment.get(0).getStar());
                        }
                        rating.setStar(da);
                        if (TextUtils.isEmpty(getOrderdetailscomment.get(0).getComment())) {
                            comments.setText("暂无用户评价");
                        } else {
                            comments.setText(getOrderdetailscomment.get(0).getComment());
                        }

                    }
                }
            }
        }
    }

    //家政 洗车商家
    private void processhomemaking(String content) {
        List<OrderDetailsModel> getOrderdhomemaking = JsonTools.getOrderdhomemaking(content);
        if (getOrderdhomemaking != null && getOrderdhomemaking.size() > 0) {


            String comment = getOrderdhomemaking.get(0).getComment();

            number.setText(getOrderdhomemaking.get(0).getOrdernumber());
            time.setText(Sundry.getStrTime(4, getOrderdhomemaking.get(0).getAddtime()));
            if (getOrderdhomemaking.get(0).getPayment().equals("2")) {
                method_payment.setText("微信支付");
            } else if (getOrderdhomemaking.get(0).getPayment().equals("3")) {
                method_payment.setText("支付宝支付");
            } else if (getOrderdhomemaking.get(0).getPayment().equals("4")) {
                method_payment.setText("银联支付");
            } else if (getOrderdhomemaking.get(0).getPayment().equals("5")) {
                method_payment.setText("余额支付");
            }
            if (merchanttype.equals("8")) {
                name.setText(getOrderdhomemaking.get(0).getConsignee() + "    " + getOrderdhomemaking.get(0).getTel());
                disttel = getOrderdhomemaking.get(0).getTel();
                standbynote.setText(getOrderdhomemaking.get(0).getRemaek());
                address.setText(getOrderdhomemaking.get(0).getAddress());
            }

            //    if (pos.equals("2")) {
            List<OrderDetailsModel> getOrderdetailscomment = JsonTools.getOrderdetailscomment(comment);
            if (getOrderdetailscomment != null && getOrderdetailscomment.size() > 0) {
                float da = 0;
                if (!TextUtils.isEmpty(getOrderdetailscomment.get(0).getStar())) {
                    da = Float.valueOf(getOrderdetailscomment.get(0).getStar());
                }
                rating.setStar(da);
                if (TextUtils.isEmpty(getOrderdetailscomment.get(0).getComment())) {
                    comments.setText("暂无用户评价");
                } else {
                    comments.setText(getOrderdetailscomment.get(0).getComment());
                }

            }
            // }
        }
    }

    //买房 买车  开锁
    private void processbuyhouse(String content) {
        List<OrderDetailsModel> getOrderdhomemaking = JsonTools.getOrderdhomemaking(content);
        if (getOrderdhomemaking != null && getOrderdhomemaking.size() > 0) {
            String comment = getOrderdhomemaking.get(0).getComment();

            number.setText(getOrderdhomemaking.get(0).getOrdernumber());
            time.setText(Sundry.getStrTime(4, getOrderdhomemaking.get(0).getAddtime()));
            method_payment.setText(getOrderdhomemaking.get(0).getOrdername());
            if (merchanttype.equals("4")){
                disttel = getOrderdhomemaking.get(0).getTel();
                if (getOrderdhomemaking.get(0).getIscharge().equals("2")) {
                    order_phone.setVisibility(View.GONE);
                    address.setVisibility(View.GONE);
                    name.setText(getOrderdhomemaking.get(0).getPerson()+"    "+Sundry.getphon(getOrderdhomemaking.get(0).getTel()));
                } else {
                    order_phone.setVisibility(View.VISIBLE);
                    name.setText(getOrderdhomemaking.get(0).getPerson()+"    "+getOrderdhomemaking.get(0).getTel());
                    address.setText(getOrderdhomemaking.get(0).getAddress()+getOrderdhomemaking.get(0).getDetailedaddress());
                    address.setVisibility(View.VISIBLE);
                }
            }else {
                disttel = getOrderdhomemaking.get(0).getPhone();
                if (getOrderdhomemaking.get(0).getIscharge().equals("2")) {
                    order_phone.setVisibility(View.GONE);
                    name.setText(Sundry.getphon(getOrderdhomemaking.get(0).getPhone()));
                } else {
                    order_phone.setVisibility(View.VISIBLE);
                    name.setText(getOrderdhomemaking.get(0).getPhone());
                }
            }


            //    if (pos.equals("2")) {
            List<OrderDetailsModel> getOrderdetailscomment = JsonTools.getOrderdetailscomment(comment);
            if (getOrderdetailscomment != null && getOrderdetailscomment.size() > 0) {
                float da = 0;
                if (!TextUtils.isEmpty(getOrderdetailscomment.get(0).getStar())) {
                    da = Float.valueOf(getOrderdetailscomment.get(0).getStar());
                }
                rating.setStar(da);
                if (TextUtils.isEmpty(getOrderdetailscomment.get(0).getComment())) {
                    comments.setText("暂无用户评价");
                } else {
                    comments.setText(getOrderdetailscomment.get(0).getComment());
                }

            }
            // }
        }
    }
//苦力
    private void processcoolie(String content) {
        List<OrderDetailsModel> getOrderdcoolie = JsonTools.getOrderdcoolie(content);
        if (getOrderdcoolie != null && getOrderdcoolie.size() > 0) {
            String comment = getOrderdcoolie.get(0).getComment();

            number.setText(getOrderdcoolie.get(0).getOrdernumber());
            time.setText(Sundry.getStrTime(4, getOrderdcoolie.get(0).getAddtime()));
            method_payment.setText(getOrderdcoolie.get(0).getWeight());

                disttel = getOrderdcoolie.get(0).getGophone();
            pickup_phone = getOrderdcoolie.get(0).getPhone();
                if (getOrderdcoolie.get(0).getIscharge().equals("2")) {
                    order_phone.setVisibility(View.GONE);
                    address.setVisibility(View.GONE);
                    name.setText(getOrderdcoolie.get(0).getGoname()+"    "+Sundry.getphon(getOrderdcoolie.get(0).getGophone()));
                    pickupgoodsorder_phone.setVisibility(View.GONE);
                    pickupgoodsaddress.setVisibility(View.GONE);
                    pickupgoodsname.setText(Sundry.getphon(getOrderdcoolie.get(0).getPhone()));
                } else {
                    order_phone.setVisibility(View.VISIBLE);
                    name.setText(getOrderdcoolie.get(0).getGoname()+"    "+getOrderdcoolie.get(0).getGophone());
                    address.setText(getOrderdcoolie.get(0).getGoaddress()+getOrderdcoolie.get(0).getGonum());
                    address.setVisibility(View.VISIBLE);
                    pickupgoodsorder_phone.setVisibility(View.VISIBLE);
                    pickupgoodsname.setText(getOrderdcoolie.get(0).getPhone());
                    pickupgoodsaddress.setText(getOrderdcoolie.get(0).getQuaddress()+getOrderdcoolie.get(0).getQuhousnum());
                    pickupgoodsaddress.setVisibility(View.VISIBLE);
                }
            standbynote.setText(getOrderdcoolie.get(0).getRemarks());
            //    if (pos.equals("2")) {
            List<OrderDetailsModel> getOrderdetailscomment = JsonTools.getOrderdetailscomment(comment);
            if (getOrderdetailscomment != null && getOrderdetailscomment.size() > 0) {
                float da = 0;
                if (!TextUtils.isEmpty(getOrderdetailscomment.get(0).getStar())) {
                    da = Float.valueOf(getOrderdetailscomment.get(0).getStar());
                }
                rating.setStar(da);
                if (TextUtils.isEmpty(getOrderdetailscomment.get(0).getComment())) {
                    comments.setText("暂无用户评价");
                } else {
                    comments.setText(getOrderdetailscomment.get(0).getComment());
                }

            }
            // }
        }
    }
}
